<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"/>
	<title>demo1</title>
	<meta name="keywords" content=""/>
	<meta name="description" content=""/>
	<meta name="viewport" content="width=device-width"/>
	<link rel="shortcut icon" href="img/touchicon.png"/>
	<link rel="stylesheet" href=""/>
	<style type="text/css">
		#output{margin-top:10px;width:500px;height:200px;outline:1px solid #cdcdcd;}
	</style>
</head>
<body>
	<input type="button" value="评分：" id="btn">
	<input type="text" id="input">
	<div id="output">	
	</div>
	<script>
		var inPut,btn,outPut;
		inPut = document.getElementById('input');
		btn = document.getElementById('btn');
		outPut = document.getElementById('output');	

		btn.onclick = function foo () {
			var s = '';
			var v = Number(inPut.value);  //使用Number()方法转换字符串为数字，当转换失败时，输出NaN，也可以 var v = +inPut.value;
			v = Math.floor(v);
			if (isNaN(v)||(v>10 || v <0)){
				alert('输入格式错误')
				console.log(v);
			} else if (v==10) {
				s = s + v + ', 成绩满分';
			} else if (v==9) {
				s = s + v + ', 成绩优秀';
			} else if (v==8) {
				s = s + v + ', 成绩良好';
			} else if (v==7) {
				s = s + v + ', 成绩一般';
			} else if (v==6) {
				s = s + v + ', 成绩及格';
			} else{
				s = s + v + ', 成绩不及格';
			}
			outPut.innerHTML = '你的分数是：' + s ;
		}
		
	</script>
</body>
</html>